package com.example.myapplication.slice;

import com.example.myapplication.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Image;
import ohos.agp.components.Text;

public class HealthCode extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_health_code);

        Text healthCodeName = findComponentById(ResourceTable.Id_health_code_name_text);
        Text healthCodeId = findComponentById(ResourceTable.Id_health_code_ID_text);
        Image healthCodeEye = findComponentById(ResourceTable.Id_health_code_eye_img);
        //Text healthCodeTime = findComponentById(ResourceTable.Id_health_code_time_text);


        //点击小眼睛隐藏信息
        healthCodeEye.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
            boolean flag = false;
                if (!flag){
                    String healthCodeNameHidden = healthCodeName.getText();
                    healthCodeName.setText("**"+healthCodeNameHidden.substring(3));
                    String healthCodeIdHidden = healthCodeId.getText();
                    healthCodeId.setText(healthCodeIdHidden.substring(0,3)+"**************"+healthCodeIdHidden.substring(17));
                    healthCodeEye.setPixelMap(ResourceTable.Media_eyeClose);
                    flag = true;
                }
            }
        });

    }
}
